
#include "ax_common.h"
#include "config.h"
#include "global.h"

unsigned short GConf::netd_port = 8884;
unsigned int GConf::max_online = 1000;
int GConf::fps = 10;   //server frame rate
char GConf::log_path[512] = "./";
char GConf::log_debug_name[128] = "debug.log";

int GConf::reload_config(const char* file)
{
	int val, ret;
	const char *s;
	AxIniParser pconf;
	ret = pconf.parse(file);
	if (ret == -1) {
		debug_msg("file:%s not exist", file);
		return -1;
	} else if( ret == -2) {
		debug_msg("config file error. file=%s lineno= %d", file, pconf.get_error());
		return -1;
	}

	debug_msg("reload config file: %s", file);

	val = pconf.get_int("SYS", "netd_port");	
	if (val) GConf::netd_port = val;
	val = pconf.get_int("SYS", "fps");
	if (val) GConf::fps = val;

	s = pconf.get_string("SYS", "logpath");
	if (strlen(s) > 0) strncpy(GConf::log_path, s, 512);
	s = pconf.get_string("SYS", "debugname");
    if (strlen(s) > 0) strncpy(GConf::log_debug_name, s, 128);
	
	val = pconf.get_int("GAME", "max_online");
	if (val) GConf::max_online = val;

	return 0;
}


